<!DOCTYPE>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>客户开发计划</title>
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/client/style.css" type="text/css">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/admin-all.css" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/bootstrap.min.css" />
    <script src="${pageContext.request.contextPath}/js/layui/layui.all.js"></script>
    <script src="${pageContext.request.contextPath}/js/jquery/jquery-3.3.1.js"></script>

    <script type="text/javascript">
        layui.use('laydate', function(){
            var laydate = layui.laydate;
            laydate.render({
            elem: '#plan_date'
            ,type: 'datetime'
            });
        });
    </script>

    <script type="text/javascript">
        function checkNull() {
            var plan_date = $("#plan_date").val();
            var plan_desc = $("#plan_desc").val();
            if(plan_date.trim()=="" || plan_desc.trim()==""){

                layer.alert("日期和计划项不允许为空!");
                return false;
            }
            return true;
        }
    </script>
</head>
<body>
<div class="alert alert-info">客户开发计划<b class="tip"></b>制订开发计划</div>
<div class="button_bar">
    <input type="button" class="common_button" onclick="layer.alert('欢迎使用!');" value="帮助"/>
	<input type="button" class="common_button" onclick="window.history.go(-1);" value="返回"/>
</div>


<table class="query_table">
    <tr>
        <th>编号</th>
        <td>${saleChance.id}</td>
        <th>机会来源</th>
        <td>${saleChance.opportunity_source}</td>
    </tr>
    <tr>
        <th>客户名称</th>
        <td>${saleChance.customer_name}</td>
        <th>成功机率(%)</th>
        <td>${saleChance.success_probability}</td>
    </tr>
    <tr>
        <th>概要</th>
        <td colspan="3">${saleChance.summarize}</td>
    </tr>
    <tr>
        <th>联系人</th>
        <td>${saleChance.linkman}</td>
        <th>联系人电话</th>
        <td>${saleChance.link_tel}</td>
    </tr>
    <tr>
        <th>机会描述</th>
        <td colspan="3">${saleChance.opportunity_desc}</td>
    </tr>
    <tr>
        <th>创建人</th>
        <td>${saleChance.creator}</td>
        <th>创建时间</th>
        <td>${saleChance.create_time}</td>
    </tr>
</table>

</br>


<table class="data_table">
   <tr><th width="19%">日期</th><th width="81%">计划项</th></tr>
    <c:forEach items="${planList}" var="plan" varStatus="status">
   <tr>
       <td><span id="" name="plan_date">${plan.plan_date}</span></td>
     <td> 
	     <input name="plan_desc" type="text" value="${plan.plan_desc}"/>
         <input type="button" value="保存" id="obj" onclick="updPlan(this)"/>
         <input type="hidden" id="pid" name="pid"  value="${plan.id}"/>
	     <input type="button" value="删除" onclick="del(${plan.id});"/>
     </td>
   </tr>
    </c:forEach>
</table>

    <input type="hidden" id="msg" value="${msg}"/>

<form action="savePlan" method="post" >
<div class="button_bar">
   <input type="submit" class="common_button"  value="保存" onClick="return checkNull()"/>
</div>
<table class="query_table">
 <tr><th>日期</th>
     <td>
     <input type="text"  class="layui-input" id="plan_date" name="plan_date"
            placeholder="yyyy-MM-dd HH:mm:ss"/>
         <span class="red_star">*</span>
     </td><th>计划项</th>
     <td>
         <input type="text" name="plan_desc" id="plan_desc" size="50"/>
         <span class="red_star">*</span>
     </td>
 </tr>
</table>
    <input type="hidden" name="cus_id" value="${saleChance.id}"/>
</form>

    <script type="text/javascript">
    function del(id) {
        layer.confirm('确定要删除?',{
                btn: ['确定','取消'] }, //按钮
            function(){
                window.location.href="delPlan?id="+id;
            },function(){
                layer.msg('的确很重要', {icon: 1});
            })
    }
    function updPlan(obj) {
        //prev()返回上一个兄弟节点
        // 如果有多个元素有相同id $("#obj") 只能获取到第一个
        // var plan_desc =$("#obj").prev().val();
        var plan_desc = $(obj).prev().val();
        layer.alert(plan_desc);
        //  next(),返回下一个兄弟节点，不是所有的兄弟节点
        var pid = $(obj).next().val();
        // var cus_id = $("#cus_id").val();
        //layer.alert(cus_id);
        // 框架会自动将参数 封装为对象属性
        window.location.href="updPlan?id="+pid+"&plan_desc="+plan_desc+"&type=makePlan";
    }
    </script>

<script type="javascript">
   var msg =  $("#msg").val();
   if(msg=="保存成功!"){
       layer.alert(msg);
      /* setTimeout(go,2000);
       function go(){
           window.location.href="makePlan?id=";
       }*/
   }
</script>

</body>

</html>
